Document how to use npm packages and env input#126
Merged
joshmgross merged 3 commits intoactions:mainfrom Mar 29, 2021
nihalgonsalves:ng/input
Merged
Document how to use npm packages and env input#126joshmgross merged 3 commits intoactions:mainfrom nihalgonsalves:ng/input
joshmgross merged 3 commits intoactions:mainfrom
nihalgonsalves:ng/input
Conversation
Contributor
|
Would step environment variables work here and avoid the quotes issue? A couple concerns with this approach:
If environment variables support your case, I'd prefer we document how to use those as inputs. For example: - uses: actions/github-script@v3
env:
FIRST_NAME: Mona
LAST_NAME: Octocat
with:
script: console.log(`Hello ${process.env.FIRST_NAME} ${process.env.LAST_NAME}`) |
input variable
Contributor
Author
|
@joshmgross Thanks - not sure why I didn't think of that. It works perfectly. I updated my PR to simply update the README. |
joshmgross
approved these changes
Mar 29, 2021
Contributor
joshmgross
left a comment
There was a problem hiding this comment.
Awesome, thanks for this!
Contributor
Author
|
I updated the npm command example to remove the Thanks for the quick review! :) |
joshmgross
approved these changes
Mar 29, 2021
joshmgross
approved these changes
Mar 29, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ℹ️ Updated to document
envandprocess.envas inputs.We've been using
actions/github-scriptto glue together different build tools. We've had cases where we want to passthrough outputs of other scripts to this action –One way would be to just use an input value:
which works, but displays this warning:
Another way would be to inline the value:
but this can cause issues depending on what the value of the string is, and requires you to be aware of how your string will interact with the program:
So this PR introduces a simple
inputvariable that is exposed directly to the function:It can be combined with
JSON.parse(input)in the script to pass through stringified JSON (from other jobs or CLI tools, for example).I also made two other changes